var object = {};
_.extend(object, Backbone.Events);

object.on("alert", function(msg) {
  alert(msg);
});

object.trigger("alert", "Kapil Kashyap");

var Person = Backbone.Model.extend({
	defaults: {
		name: "Kashyap",
		married: false
	},
	validate: function( attributes ) {
		if(attributes.age < 0) {
			return "-ve values for age are not acceptable.";
		}
	},
	initialize: function() {
		this.bind("change", function() {
			if(this.hasChanged("name")) {
				alert("Changed my name from " + this.previous("name") + " to " + this.get("name"));
			}
			if(this.hasChanged("married")) {
				alert("I am " + (this.get("married") ? "married." : "not married."));
			}
		});
		this.bind("error", function(model, error) {
			alert( error );
		});
	}
});
